<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="/0505/js/jq.js"></script>
</head>
<body>
    <button class="add">post</button>
    <button class="add1">post1</button>
    <script>
        $(function () {
            let pro = (url,type='get', data) => {
                console.log(34, data);
                return new Promise((resolve, reject, data) => {
                    $.ajax({
                        url,
                        type,
                        contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                        data: {name: 'ddaa33', password: '123fsdf'},
                        success(res) {
                            resolve(res)
                        },
                        error(err) {
                            reject(err)
                        }
                    })
                })
            }
            async function getGoodsList() {
                let res = await pro('http://localhost:8080/goodslist?name=aa');
                console.log(res);
            }
            async function addGoods() {
                let data = {name: 'aa'}
                let res = await pro('http://localhost:8080/add', 'post', data);
                console.log(res);
            }

            $('.add').click(function () {
                addGoods()
            })

            $('.add1').click(function() {
                $.ajax({
                    url: 'http://localhost:3000/users/login',
                    type: 'post',
                    contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                    data: {name: 'ddaa33', password: '123fsdf'},
                    success(res) {
                        console.log(res);
                    }
                })
            })
        })
    </script>
</body>
</html>